import jsonp from './jsonp';

export const getCommodity = (page = 1, psize=20)=>{
    const url = 'https://ju.taobao.com/json/tg/ajaxGetItemsV2.json';

    const params = {
        page,
        psize,
        type: 0,
        frontCatId: ''
    };
    return jsonp(url ,params,{
        param: 'callback'
    }).then(res=>{
        if(res.code === '200'){
            return res;
        }
        throw new Error('there is no data!')
    }).catch(err => {
        console.log(err)
    }).then(data => {
        return new Promise(resolve => {
            setTimeout(()=>{
                resolve(data)
            },1000)
        })
    })

}